package org.myself.meeting.service;

import org.myself.meeting.Utils.Constant;
import org.myself.meeting.mapper.MeetingRoomMapper;
import org.myself.meeting.mapper.NewMessageMapper;
import org.myself.meeting.model.Employee;
import org.myself.meeting.model.MeetingRoom;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MeetingRoomService {
    @Autowired
    MeetingRoomMapper meetingRoomMapper;

    @Autowired
    NewMessageMapper nmmp;

    public List<MeetingRoom> getAllmrs() {
        return meetingRoomMapper.getAllmrs();
    }

    public MeetingRoom getMrById(Integer roomid) {
        return meetingRoomMapper.getMrById(roomid);
    }

    public Integer updateRoom(MeetingRoom meetingRoom, Employee emp) {
        String operation = emp.getEmployeename()+" 更新了会议室 "+meetingRoom.getRoomname();
        nmmp.addNewMessage(Constant.ADDMEETINGROOM,operation,new Date());
        return meetingRoomMapper.updateRoom(meetingRoom);
    }

    public Integer addMr(MeetingRoom meetingRoom, Employee emp) {
        String operation = emp.getEmployeename()+" 添加了会议室 "+meetingRoom.getRoomname();
        nmmp.addNewMessage(Constant.ADDMEETINGROOM,operation,new Date());
        return meetingRoomMapper.addMr(meetingRoom);
    }

    public List<MeetingRoom> getAllmrsOutStatus(Integer status) {
        return meetingRoomMapper.getAllmrsOutStatus(status);
    }
}
